//
//  GJMapHUDView.m
//  xmgjAppFront
//
//  Created by ZekiMini on 2020/9/1.
//  Copyright © 2020 guojutech. All rights reserved.
//

#import "GJMapHUDView.h"

@interface GJMapHUDView ()
@property (nonatomic, strong)UILabel *leftLabel;
@property (nonatomic, strong)UILabel *rightLabel;
@property (nonatomic, strong)UILabel *centerLabel;
@property (nonatomic, strong)UIView *imageView;
@end

@implementation GJMapHUDView

- (instancetype)initWithFrame:(CGRect)frame
{
  self = [super initWithFrame:frame];
  if (self) {
    self.backgroundColor = [UIColor whiteColor];
    self.layer.masksToBounds = YES;
    self.layer.cornerRadius = 18;
    [self initlizationSubViews];
  }
  return self;
}
- (void)initlizationSubViews{
  [self addSubview:self.imageView];
  [self addSubview:self.leftLabel];
  [self addSubview:self.centerLabel];
  [self addSubview:self.rightLabel];
  
  [self.imageView mas_makeConstraints:^(MASConstraintMaker *make) {
    make.left.mas_equalTo(4);
    make.centerY.equalTo(self);
    make.width.height.mas_equalTo(28);
  }];
  [self.leftLabel mas_makeConstraints:^(MASConstraintMaker *make) {
    make.left.equalTo(self.imageView.mas_right).offset(10);
    make.top.bottom.equalTo(self);
    make.width.mas_equalTo([self.leftLabel.text widthForFont:self.leftLabel.font]);
  }];
  [self.centerLabel mas_makeConstraints:^(MASConstraintMaker *make) {
    make.centerY.equalTo(self);
    make.left.equalTo(self.leftLabel.mas_right);
    make.right.equalTo(self.rightLabel.mas_left);
  }];
  [self.rightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
    make.top.bottom.equalTo(self);
    make.right.mas_equalTo(-16);
    make.width.mas_equalTo([self.rightLabel.text widthForFont:self.rightLabel.font] + 4);
  }];
}
#pragma mark -- setter
- (void)setNumberString:(NSString *)numberString{
  _numberString = numberString;
  self.centerLabel.text = numberString;
}
#pragma mark -- getter
- (UIView *)imageView{
  if (!_imageView) {
    _imageView = [[UIView alloc]initWithFrame:CGRectZero];
    _imageView.backgroundColor = HexColor(#BA914A);
    _imageView.layer.cornerRadius = 14;
    _imageView.layer.masksToBounds = YES;
    UIImageView *subView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"icon_broadcast"]];
    [_imageView addSubview:subView];
    [subView mas_makeConstraints:^(MASConstraintMaker *make) {
      make.width.height.mas_equalTo(16);
      make.center.equalTo(_imageView);
    }];
  }
  return _imageView;
}

- (UILabel *)leftLabel{
  if (!_leftLabel) {
    _leftLabel = [[UILabel alloc]initWithFrame:CGRectZero];
    _leftLabel.font = kSystemFontOfSize(14);
    _leftLabel.textColor = HexColor(#343332);
    _leftLabel.text = @"附近有";
  }
  return _leftLabel;
}

- (UILabel *)rightLabel{
  if (!_rightLabel) {
    _rightLabel = [UILabel new];
    _rightLabel.font = kSystemFontOfSize(14);
    _rightLabel.textColor = HexColor(343332);
    _rightLabel.text = @"位司机等待您发货";
    _rightLabel.textAlignment = NSTextAlignmentRight;
  }
  return _rightLabel;
}

- (UILabel *)centerLabel{
  if (!_centerLabel) {
    _centerLabel = [UILabel new];
    _centerLabel.textColor = HexColor(#BA914A);
    _centerLabel.font = kBoldSystemFontOfSize(14);
    _centerLabel.textAlignment = NSTextAlignmentCenter;
  }
  return _centerLabel;
}
@end
